# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Domains.V1.Model.WrrPolicyItem do
  @moduledoc """
  A routing block which contains the routing information for one WRR item.

  ## Attributes

  *   `healthCheckedTargets` (*type:* `GoogleApi.Domains.V1.Model.HealthCheckTargets.t`, *default:* `nil`) - Endpoints that are health checked before making the routing decision. The unhealthy endpoints are omitted from the result. If all endpoints within a bucket are unhealthy, we choose a different bucket (sampled with respect to its weight) for responding. If DNSSEC is enabled for this zone, only one of `rrdata` or `health_checked_targets` can be set.
  *   `rrdata` (*type:* `list(String.t)`, *default:* `nil`) - 
  *   `signatureRrdata` (*type:* `list(String.t)`, *default:* `nil`) - DNSSEC generated signatures for all the `rrdata` within this item. When using health-checked targets for DNSSEC-enabled zones, you can only use at most one health-checked IP address per item.
  *   `weight` (*type:* `float()`, *default:* `nil`) - The weight corresponding to this `WrrPolicyItem` object. When multiple `WrrPolicyItem` objects are configured, the probability of returning an `WrrPolicyItem` object's data is proportional to its weight relative to the sum of weights configured for all items. This weight must be non-negative.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :healthCheckedTargets => GoogleApi.Domains.V1.Model.HealthCheckTargets.t() | nil,
          :rrdata => list(String.t()) | nil,
          :signatureRrdata => list(String.t()) | nil,
          :weight => float() | nil
        }

  field(:healthCheckedTargets, as: GoogleApi.Domains.V1.Model.HealthCheckTargets)
  field(:rrdata, type: :list)
  field(:signatureRrdata, type: :list)
  field(:weight)
end

defimpl Poison.Decoder, for: GoogleApi.Domains.V1.Model.WrrPolicyItem do
  def decode(value, options) do
    GoogleApi.Domains.V1.Model.WrrPolicyItem.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Domains.V1.Model.WrrPolicyItem do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
